home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Archive Magazine CD 1995
/
Archive Magazine CD 1995.iso
/
discs
/
shareware
/
share_41
/
assembler
/
examples
/
dec_bin
< prev
next >
Wrap
Text File
|
1991-05-15
|
999b
|
41 lines
; NAME dec_bin
; PURPOSE converts the decimal number1 to a binary bit pattern in text1
; DESIGN
; load number1
; for i <- 31 down to 0
; asl number1
; if carry = 1
; then
; character = '1'
; else
; character = '0'
; endif
; place character at end of text1
; increment text pointer
; end for
; place control character at end of text1
; NOTE
; r1 stores the address of number to be converted
; r4 stores the address of the converted string
; r6 is loaded with the number to be converted
; r7 is used as a loop counter
; r8 holds a '1' or '0' depending on the carry flag
ldr r6, [r1]
mov r7, #31
.loop
movs r6, r6, lsl #1
movcc r8, #48
movcs r8, #49
strb r8, [r4]
add r4, r4, #1
subs r7, r7, #1
bpl loop
mov r8, #0
strb r8, [r4]